/**
 * Copyright 2013 Viettel Telecom. All rights reserved.
 * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.viettel.core.entities.cms;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

import com.viettel.core.enumtype.MediaArticleStatus;

/**
 *  Mo ta muc dich cua lop (interface)
 *  @author: ToanTM1
 *  @version: 2.1
 *  @since: 03-03-2014 - 17:31:13
 */
@Entity
@Table(name = "MEDIA_ARTICLE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@SequenceGenerator(name = "SEQ_STORE", sequenceName = "MEDIA_ARTICLE_SEQ", allocationSize = 1)
public class MediaArticle implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -4077510445266546409L;
	/**
	 * ID
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE")
	@Column(name = "ID")
//	@Index(name="MEDIA_ARTICLE_ID_PK")
	private Integer id;
	
	/**
	 * TO BAO
	 */
	@ManyToOne(targetEntity = Media.class)
	@JoinColumn(name = "MEDIA_ID", referencedColumnName = "id")
	@ForeignKey(name = "MEDIA_ARTICLE_MEDIA_FK")
	private Media media;
	
	/**
	 * SMS THUOC BAI VIET
	 */
	@ManyToOne(targetEntity = Article.class)
	@JoinColumn(name = "ARTICLE_ID", referencedColumnName = "id")
	@ForeignKey(name = "MEDIA_ARTICLE_ARTICLE_FK")
	private Article article;
	
	/**
	 * NOI DUNG DE GUI SMS
	 */
	@Basic
	@Column(name = "SMS_CONTENT", length = 480)
	private String smsCcontent;
	
	/**
	 * TRANG THAI SMS
	 */
	@Basic
	@Column(name = "STATUS", columnDefinition = "NUMBER(1,0)", nullable = false)
	@Type(type = "com.viettel.core.enumtype.GenericEnumUserType", parameters = {
			@Parameter(name = "enumClass", value = "com.viettel.core.enumtype.MediaArticleStatus"),
			@Parameter(name = "identifierMethod", value = "getValue"),
			@Parameter(name = "valueOfMethod", value = "parseValue") })
	@Index(name="MEDIA_ARTICLE_STATUSX")
	private MediaArticleStatus status;
	
	/**
	 * CMSUSER MODIFIED
	 */
	@ManyToOne(targetEntity = CmsUser.class)
	@JoinColumn(name = "CMS_USER_ID", referencedColumnName = "id")
	@ForeignKey(name = "MEDIA_ARTICLE_CMS_USER_FK")
	private CmsUser cmsUser;
	
	/**
	 * THOI GIAN GUI
	 */
	@Basic
	@Column(name = "SENT_TIME", columnDefinition = "timestamp(9) default systimestamp", insertable = true, updatable = true)
	@Temporal(TemporalType.TIMESTAMP)
	private Date sentTime;
	
	/**
	 * THOI GIAN TAO
	 */
	@Basic
	@Column(name = "CREATED_TIME", columnDefinition = "timestamp(9) default systimestamp", insertable = false, updatable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date createdTime;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Media getMedia() {
		return media;
	}

	public void setMedia(Media media) {
		this.media = media;
	}

	public Article getArticle() {
		return article;
	}

	public void setArticle(Article article) {
		this.article = article;
	}

	public String getSmsCcontent() {
		return smsCcontent;
	}

	public void setSmsCcontent(String smsCcontent) {
		this.smsCcontent = smsCcontent;
	}

	public MediaArticleStatus getStatus() {
		return status;
	}

	public void setStatus(MediaArticleStatus status) {
		this.status = status;
	}

	public CmsUser getCmsUser() {
		return cmsUser;
	}

	public void setCmsUser(CmsUser cmsUser) {
		this.cmsUser = cmsUser;
	}

	public Date getSentTime() {
		return sentTime;
	}

	public void setSentTime(Date sentTime) {
		this.sentTime = sentTime;
	}

	public Date getCreatedTime() {
		return createdTime;
	}

	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}
	
}
